package com.csun.cmny.provider.service;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.IService;
import com.csun.cmny.provider.model.domain.DmcDevice;
import com.csun.cmny.provider.model.domain.DmcDeviceAlert;
import com.csun.cmny.provider.model.dto.device.DeviceBindDto;
import com.csun.cmny.provider.model.dto.device.DevicePageQuery;
import com.csun.cmny.provider.model.dto.device.DeviceQueryDto;
import com.csun.cmny.provider.model.dto.device.DeviceReqDto;
import com.csun.cmny.provider.model.dto.propertyManagement.DeviceDeriveExcelDto;
import com.csun.cmny.provider.model.dto.propertyManagement.MerchantSaveDeviceDto;
import com.csun.cmny.provider.model.dto.version.DeviceUpdateDto;
import com.csun.cmny.provider.model.vo.DeviceCountVo;
import com.csun.cmny.provider.model.vo.IsInRoomVO;
import com.csun.cmny.provider.model.vo.csuncamera.GroupCameraVo;
import com.csun.cmny.provider.model.vo.device.DeviceTypeVo;
import com.csun.cmny.provider.model.vo.device.DmcDeviceVo;
import com.csun.cmny.provider.model.vo.life.DmcDeviceByRoom;
import com.csun.cmny.provider.model.vo.propertyManagement.PropertyManagementDeviceVo;
import com.github.pagehelper.PageInfo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2018-12-12 10:25
 * @Description:
 */
public interface DmcDeviceService extends IService<DmcDevice> {

    /**
     * add dmc group device
     *
     * @param dmcDevice     the dmc device
     * @param loginAuthDto  the login auth dto
     *
     * @return the int
     */
    Integer addDevice(DmcDevice dmcDevice, LoginAuthDto loginAuthDto);

    /**
     * 根据设备Id查询设备信息
     *
     * @param deviceId 设备Id
     *
     * @return 设备信息
     */
    DeviceReqDto getDeviceById(Long deviceId);

    /**
     * query group device list with page
     *
     * @param devicePageQuery     the device query
     *
     * @return  the page info
     */
    PageInfo queryDeviceListWithPage(DevicePageQuery devicePageQuery);

    /**
     * edit dmc device
     *
     * @param dmcDevice     the dmc device
     * @param loginAuthDto  the login auth dto
     *
     * @return the int
     */
    Integer editDevice(DmcDevice dmcDevice, LoginAuthDto loginAuthDto);

    /**
     * delete dmc device by id
     *
     * @param id    the id
     *
     * @return  the int
     */
    Integer deleteDmcDeviceById(Long id);

    /**
     * check device is watch by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsWatchByDeviceId(Long deviceId);

    /**
     * check device is rfid reader by device id
     *
     * @param deviceId device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsRfidReaderByDeviceId(Long deviceId);

    /**
     * check device is rfid label by device id
     *
     * @param deviceId device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsRfidLabelByDeviceId(Long deviceId);

    /**
     * check device is phone by device id
     *
     * @param deviceId device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsPhoneByDeviceId(Long deviceId);

    /**
     * check device is csun body sensor by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsCsunBodySensorByDeviceId(Long deviceId);

    /**
     * check device is csun button by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsCsunButtonByDeviceId(Long deviceId);

    /**
     * check device is csun sleep by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsCsunSleepByDeviceId(Long deviceId);

    /**
     * check device is csun camera by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsCsunCameraByDeviceId(Long deviceId);

    /**
     * check device is sleep care by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsSleepCareByDeviceId(Long deviceId);

    /**
     * check device is follow by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsFollowByDeviceId(Long deviceId);

    /**
     * check device is csun gateway by device id
     *
     * @param deviceId  the device id
     *
     * @return  the dmc device
     */
    DmcDevice checkDeviceIsCsunGatewayByDeviceId(Long deviceId);

    /**
     * check device is radar by deviceId
     * @param deviceId
     * @return
     */
    DmcDevice checkDeviceIsRadarByDeviceId(Long deviceId);

    /**
     * query gateway list
     *
     * @return the list
     */
    List<DmcDeviceVo> queryGatewayList();


    /**
     * @description: TODO 查询所有设备的数量
     * @param:
     * @return: 设备总数
     * @throws
     * @author huangxm
     * @date 2019/3/8 14:32
     */
    Integer getDeviceSum(Long groupId, Integer deviceType);

    /**
     * get device bind dto
     *
     * @param dmcDeviceAlert    dmc device alert
     *
     * @return  the device bind dto
     */
    DeviceBindDto getDeviceBindDto(DmcDeviceAlert dmcDeviceAlert);

    DeviceBindDto getDeviceBindDtoByDeviceId(Long deviceId);

    /**
     * @param: groupId
     * @return: DeviceCountVo
     */
    List<DeviceCountVo> queryDeviceNumByGroupByDeviceType(Long groupId);

    /**
     * 通过设备编号查询通过设备编号查询设备
     * @param deviceNo
     * @return
     */
    DmcDevice queryDeviceByNumber(String deviceNo);

    /**
     * 根据设备类型查询绑定的设备
     * @param userId  用户ID
     * @param deviceType 设备类型
     * @return
     */
    List<DmcDevice> queryDeviceBindList(Long userId,Integer deviceType);

    /**
     * 根据设备id集合查询设备集合
     * @param: [deviceIdList]
     * @return: java.util.List<com.csun.cmny.provider.model.vo.DmcDeviceVo>
     */
    List<DmcDeviceVo> queryDeviceListByIdList(List<Long> deviceIdList);

    /**
     * 根据设备编号查询设备信息
     *
     * @param deviceNoList  the device no list
     *
     * @return  the list.
     */
    List<DeviceTypeVo> queryDeviceByDeviceNoList(List<String> deviceNoList);



    /**
     * 根据设备id查询设备详细信息
     *
     * @param deviceId 设备id
     *
     * @return  DmcDevice
     */
    DmcDevice checkDeviceIsBedsideCareByDeviceId(Long deviceId);

    /**
     * 分页查询床头屏设备
     *
     * @param id 根据设备id查询床头屏设备
     *
     * @return  the list.
     */
    DmcDevice checkDeviceIsCsunbedsideBindByDeviceId(Long id);


    /**
     * 分页查询床头屏设备
     *
     * @param devicePageQuery
     *
     * @return  the list.
     */
    PageInfo queryBedsideListWithPage(DevicePageQuery devicePageQuery);

    /**
     * 分页查询床头屏设备-崇明
     *
     * @param devicePageQuery
     *
     * @return  the list.
     */
    PageInfo queryCMBedsideListWithPage(DevicePageQuery devicePageQuery);

    /**
     * 根据设备编号查询设备信息
     *
     * @param
     *
     * @return  the list.
     */
    List<DmcDeviceByRoom> selectDeviceByRoomId(Long roomId,Long groupId);

    /**
     * 根据设备id查询房间id
     * @param deviceIds
     * @return
     */
    List<DmcDeviceByRoom> selectRoomIdByDevice(List<Long> deviceIds);

    /*
     * 判断老人是否在房
     * */
    IsInRoomVO getIsInRoomStatus(Long roomId);

    /**
     * 查询待升级版本号的设备
     *
     * @param deviceUpdateDto   the device update dto
     *
     * @return  the list.
     */
    List<DmcDevice> queryUpdateDeviceList(DeviceUpdateDto deviceUpdateDto);

    /**
     * 更新设备版本号
     *
     * @param deviceId      the device id
     * @param deviceVersion the device version
     *
     * @return the int.
     */
    Integer updateDeviceVersion(Long deviceId, String deviceVersion);

    /**
     * 更新设备版本号
     *
     * @param deviceNo  the device no
     * @param version   the version
     *
     * @return  the int.
     */
    Integer updateDeviceVersionByDeviceNo(String deviceNo, String version);

    /**
     * 查询设备列表
     *
     * @param deviceQueryDto    the device query dto
     *
     * @return  the list
     */
    List<DmcDevice> queryDeviceList(DeviceQueryDto deviceQueryDto);

    /**
     * check device is csun body sensor by device id
     *
     * @param deviceId  device id
     *
     * @return  the device
     */
    DmcDevice checkDeviceIsCsunNewBodySensorByDeviceId(Long deviceId);


    List<PropertyManagementDeviceVo> selectDeviceByDeviceIds(DeviceDeriveExcelDto deriveExcelDto);

    int saves(List<DmcDevice> devices);

    int deleteManagements(List<Long> deviceIds);

    /**
     * select device id list
     *
     * @param devicePageQuery
     * @return
     */
    List<Long> selectDeviceIdList(DevicePageQuery devicePageQuery);


    int bindDeviceGroup(ArrayList<String> deviceNos, Long groupId);

    int bindOnedeviceGroup(MerchantSaveDeviceDto merchantSaveDeviceDto, Long groupId);

    int deleteuntie(List<Long> deviceIds);

    /**
     * 查询机构摄像头列表
     *
     * @return
     */
    List<GroupCameraVo> selectGroupCamera();
}
